using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
    public class ThamSoDAO
    {
        public static bool Update(ThamSoDTO ts)
        {
            bool kq = false;
            try
            {
                List<SqlParameter> sqlparam = new List<SqlParameter>();
                sqlparam.Add(new SqlParameter("@SoBenhNhanToiDa", ts.SoBenhNhanToiDa));
                sqlparam.Add(new SqlParameter("@TienKham",ts.TienKham));
                int n = SqlDataAccessHelper.ExecuteNoneQuery("spThamSoUpdate", sqlparam);
                if (n == 1)
                    kq = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return kq;
        }
        public static List<ThamSoDTO> Select()
        {
            List<ThamSoDTO> lst = new List<ThamSoDTO>();
            try
            {
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("spThamSoSelect");
                foreach (DataRow dr in dt.Rows)
                {
                    ThamSoDTO ts = new ThamSoDTO();
                    ts.SoBenhNhanToiDa = int.Parse(dr["SoBenhNhanToiDa"].ToString()); ;
                    ts.TienKham = float.Parse(dr["TienKham"].ToString());
                    lst.Add(ts);
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return lst;
        }
    }
}
